const setDebounce = (el, binding) => {
  const throttleTimeout = binding.value || 300
  let cbFun
  el.addEventListener('click', event => {
    if (!cbFun) {
      cbFun = setTimeout(() => {
        cbFun = null
      }, throttleTimeout)
    } else {
      event && event.stopImmediatePropagation()
    }
  }, true)
}
export default {
  // 在绑定元素的父组件被挂载后调用
  mounted (el, binding) {
    setDebounce(el, binding)
  },
  // 在包含组件的 VNode 及其子组件的 VNode 更新后调用
  update (el, binding) {
    setDebounce(el, binding)
  }
}
